package com.chinasoft.service.Impl;

import com.chinasoft.mapper.GoodMapper;
import com.chinasoft.pojo.Good;
import com.chinasoft.pojo.GoodCount;
import com.chinasoft.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodServiceImpl implements GoodService {
    @Autowired
    GoodMapper goodMapper;

    @Override
    public List<Good> findAll() {
        return goodMapper.findAll();
    }

    @Override
    public Boolean updateCount(Integer id, String count) {
        int i = goodMapper.updateCount(id, count);
        if(i == 1){
            return true;
        } else{
            return false;
        }
    }

    @Override
    public List<GoodCount> findgetNum() {
        return goodMapper.findbytype();
    }

    @Override
    public boolean insert(Good good) {
        int i = goodMapper.insert(good);
        if(i == 1){
            return true;
        } else{
            return false;
        }
    }

    @Override
    public boolean delete(Integer id) {
        int i = goodMapper.delete(id);
        if(i == 1){
            return true;
        } else{
            return false;
        }
    }

    @Override
    public boolean update(Good good) {
        int i = goodMapper.updateType(good);
        if(i == 1){
            return true;
        } else{
            return false;
        }
    }
}
